<ion-view view-title="采购单详情" show-tabs>
	<ion-content>
		<ion-list class="wrap-light2">
			<ion-item>
			    <span class="list-label text-right">单号</span>
			    <span>{{detail.order_no}}</span>
			</ion-item>

			<ion-item class="">
			    <span class="list-label text-right">发生时间</span>
			    <time>{{detail.date | date: "yyyy-MM-dd HH:mm:ss"}}</time>
			</ion-item>

			<ion-item class="item-icon-right">
			    <span class="list-label text-right">入库仓库</span>
			    <span>{{detail.warehouse.name}}</span>
			</ion-item>
			<ion-item class="item-base item-button-right state-history" ng-class="{'item-borderless':!$first,'state-current':$first,'last':$last,'state-history-expend':isExpend}" ng-repeat="sh in detail.state_history | orderBy: '-operation.state'" ng-if="isExpend || $first">

				<div class="row row-nopadding">
					<span class="list-label text-right"><span ng-if="$first">状态</span></span>
					<span class="state {{stateUi[sh.operation.state].bg}}">
						<i class="icon state-icon {{stateUi[sh.operation.state].icon}} {{stateUi[sh.operation.state].color}}"></i>
					</span>
					<div class="col">
					    <span class="{{stateUi[sh.operation.state].color}}">{{sh.operation.note}}</span>
					    
					    <span class="item-note">{{sh.operator.name}}</span>
						
					     <p ng-show="isExpend" class="padding-top">
							<span class="meta">{{sh.date | date:'yyyy-MM-dd HH:mm:ss'}}</span>
						</p>
					</div>
				</div>
			   
				<button class="button button-col button-light" ng-if="$first" ng-click="toggleHistory()">历史
					<i class="icon-right" ng-class="{'ion-ios-arrow-down': !isExpend,'ion-ios-arrow-up': isExpend}"></i>
				</button>
			</ion-item>
			<ion-item ng-click="updateState()" class="royal text-center" ng-if="isExpend && (detail.state===2 || detail.state===3)"><i class="icon ion-ios-loop icon-left"></i>更新状态</ion-item>
			
			
			<ion-item class="item item-divider margin-top-large">
			    采购清单
			</ion-item>

			<ion-item class="product-property" ng-repeat="product in detail.list" ng-class="{on: isItemShown(product)}" ng-click="toggleProperty(product)">
				<h2>{{product.properties.brand.value + product.properties.model.value}}<i class="pull-right" ng-class="{'ion-ios-arrow-down': !isItemShown(product),'ion-ios-arrow-up': isItemShown(product)}"></i></h2>
				<div class="meta margin-top-small">
					<span>数量：{{product.count}}部</span>
				</div>
				<div class="prop-list item-accordion" ng-if="isItemShown(product)">
					<p ng-repeat="property in product.properties" class="prop-item" ng-if="property.name!='品牌' && property.name!='型号'">
						<span class="prop-label">{{property.name}}:</span>
						<span class="prop-value">{{property.value}}</span>
					</p>
				</div>
			</ion-item>
		</ion-list>
    </ion-content>
    <div class="bar bar-footer has-footer bar-balanced" ng-if="detail.state===4">
	    <a class="title" ng-click="inventoryInModal.show();">
	      入 库
	    </a>
  </div>
</ion-view>
